/*
 * @Description: 
 * @Version: 2.0
 * @Autor: liuwei
 * @Date: 2021-04-27 12:55:40
 * @LastEditors: liuwei
 * @LastEditTime: 2021-04-27 13:01:30
 */
/*
  将下面异步代码使用 Promise 的方法改进
  尽量用看上去像同步代码的方式
  setTimeout(function () {
    var a = 'hello'
    setTimeout(function () {
      var b = 'lagou'
      setTimeout(function () {
        var c = 'I ♥ U'
        console.log(a + b +c)
      }, 10)
    }, 10)
  }, 10)
*/

const p = (str) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve(str)
    }, 10)
  })
}

p('hello').then((value) => {
  return p(value + 'lagou')
}).then((value) => {
  return p(value + 'I Love U')
}).then(value => console.log(value))